<?php


namespace app\common\command;

use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\Output;
use think\Db;

class RepairOrder extends Command
{
    protected function configure()
    {
        $this->setName('RepairOrder')
            ->addArgument('order_id', Argument::OPTIONAL, "your order_id")
            ->setDescription('you can RepairOrder');
    }

    protected function execute(Input $input, Output $output)
    {
        $order_id = trim($input->getArgument('order_id'));

        if(empty($order_id)){
            return $output->error('order_id not empty');
        }

        // 查询订单号
        $Dbname = Db::connect('db_config2');
        $field = '
                 userid,
                 goods_id,
                 amount
                 ';
        $order_info =$Dbname->table('tradelog')->field($field)->where('id',$order_id)->find();
        if(empty($order_info)){
            return $output->warning("订单不存在");
        }

        $time= date('Y-m-d H:i:s',time());
        $res = Db_connect_server_pay_domian($order_id,$order_info['amount'],$time);
        return $output->writeln($res);
    }
}